package com.pt.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDateTime;

@Data
@TableName("history")
public class History {
    @TableId(type = IdType.AUTO)
    private Long id;
    
    private Long userId;
    
    private Long torrentId;
    
    private Long uploaded;
    
    private Long downloaded;
    
    private Integer seedTime;
    
    private Integer leechTime;
    
    private LocalDateTime startTime;
    
    private LocalDateTime lastAction;
    
    private Boolean isFinished;
    
    private LocalDateTime finishTime;
    
    private Boolean isDeleted;
    
    // 非数据库字段
    public Double getShareRatio() {
        if (downloaded == 0) {
            return 0.0;
        }
        return uploaded * 1.0 / downloaded;
    }
    
    public String getSeedTimeText() {
        if (seedTime < 3600) {
            return seedTime / 60 + "分钟";
        } else if (seedTime < 86400) {
            return seedTime / 3600 + "小时";
        } else {
            return seedTime / 86400 + "天";
        }
    }
    
    public String getLeechTimeText() {
        if (leechTime < 3600) {
            return leechTime / 60 + "分钟";
        } else if (leechTime < 86400) {
            return leechTime / 3600 + "小时";
        } else {
            return leechTime / 86400 + "天";
        }
    }
} 